
function ContextController(homeController){
	this.data = {};
	this.homeController = homeController;
	var contextControllerThis = this; // for use in closures and callbacks where this changes depending on the context
	
	if(typeof ContextController.prototype.get == "undefined"){	 
		ContextController.prototype.get = function() {
    		$( "#dialog-modal" ).dialog("open");
	        var dfd = $.Deferred(); // this one gets returned
			var options = {
				'success' : function(data) {
					contextControllerThis.data = data;
	        		$( "#dialog-modal" ).dialog("close");
				}
			};
			var jqXHR_get = new AjaxHelper(options).getJSON("/getContext.app");
			
	        var jqXHR_getTemplate = {};
	        if(typeof $.template["compiled_header_page_template"] == "undefined"){
	        	jqXHR_getTemplate = $.get('/template/header_page.html', function(templateData) {
	        		$.template("compiled_header_page_template", templateData );
	        	});
	        }
	        var deferred = $.when( jqXHR_get, jqXHR_getTemplate).then(function(){
	            $.tmpl("compiled_header_page_template", contextControllerThis.data).appendTo( "#header_page_container_id" );
				$("#loading_bar_id").hide();
	            dfd.resolve();
	        });
	        return dfd.promise();
		}
	}
}

